home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / edit / thesrc20.zip / show.c < prev    next >
C/C++ Source or Header  |  1995-01-26  |  69KB  |  1,792 lines

  1. /***********************************************************************/
  2. /* SHOW.C - Functions involving displaying the data.                   */
  3. /***********************************************************************/
  4. /*
  5.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  6.  * Copyright (C) 1991-1995 Mark Hessling
  7.  *
  8.  * This program is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU General Public License as
  10.  * published by the Free Software Foundation; either version 2 of
  11.  * the License, or any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16.  * General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to:
  20.  *
  21.  *    The Free Software Foundation, Inc.
  22.  *    675 Mass Ave,
  23.  *    Cambridge, MA 02139 USA.
  24.  *
  25.  *
  26.  * If you make modifications to this software that you feel increases
  27.  * it usefulness for the rest of the community, please email the
  28.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  29.  * This software is going to be maintained and enhanced as deemed
  30.  * necessary by the community.
  31.  *
  32.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  33.  * 36 David Road                     Phone: +61 7 849 7731
  34.  * Holland Park                      Fax:   +61 7 875 5314
  35.  * QLD 4121
  36.  * Australia
  37.  */
  38.  
  39. /*
  40. $Id: show.c 2.0 1995/01/26 16:32:00 MH Release MH $
  41. */
  42.  
  43. #include <stdio.h>
  44. #include <time.h>
  45.  
  46. #if defined(USE_EXTCURSES)
  47. # include <cur04.h>
  48. #endif
  49.  
  50. #include "the.h"
  51. #include "proto.h"
  52.  
  53. /*------------------------ function definitions -----------------------*/
  54. #ifdef PROTO
  55. static void build_lines(short,LINE *,short,short);
  56. static void show_lines(void);
  57. static void show_a_line(short);
  58. static void set_prefix_contents(LINE *,short,LINETYPE);
  59. static void show_hex_line(short);
  60. #else
  61. static void build_lines();
  62. static void show_lines();
  63. static void show_a_line();
  64. static void set_prefix_contents();
  65. static void show_hex_line();
  66. #endif
  67.  
  68. static LINE *hexshow_curr=NULL;
  69.  
  70. /***********************************************************************/
  71. #ifdef PROTO
  72. void show_heading(void)
  73. #else
  74. void show_heading()
  75. #endif
  76. /***********************************************************************/
  77. {
  78. /*-------------------------- external data ----------------------------*/
  79.  extern bool horizontal;
  80.  extern CHARTYPE display_screens;
  81. /*--------------------------- local data ------------------------------*/
  82.  short x=0,fpath_len=0,max_name=0;
  83.  LINETYPE line_number=0L;
  84.  CHARTYPE buffer[60];
  85.  CHARTYPE display_path[MAX_FILE_NAME+1];
  86.  CHARTYPE *fpath = display_path;
  87.  short num_to_delete=0,num_to_start=0,col=0;
  88.  register short i=0;
  89. /*--------------------------- processing ------------------------------*/
  90. #ifdef TRACE
  91.  trace_function("show.c:    show_heading");
  92. #endif
  93. /*---------------------------------------------------------------------*/
  94. /* If IDLINE is not to be displayed, exit now.                         */
  95. /*---------------------------------------------------------------------*/
  96.  if (!CURRENT_VIEW->id_line)
  97.    {
  98. #ifdef TRACE
  99.     trace_return();
  100. #endif
  101.     return;
  102.    }
  103. /*---------------------------------------------------------------------*/
  104. /* Reset idline to blank.                                              */
  105. /*---------------------------------------------------------------------*/
  106.  wattrset(CURRENT_WINDOW_IDLINE,set_colour(CURRENT_FILE->attr+ATTR_IDLINE));
  107.  wmove(CURRENT_WINDOW_IDLINE,0,0);
  108.  my_wclrtoeol(CURRENT_WINDOW_IDLINE);
  109. /*---------------------------------------------------------------------*/
  110. /* Get line,col values only if POSITION is ON...                       */
  111. /*---------------------------------------------------------------------*/
  112.  if (CURRENT_VIEW->position_status)
  113.     get_current_position(&line_number,&x);
  114. /*---------------------------------------------------------------------*/
  115. /* Set up buffer for line,col,size and alt values for vertical screens.*/
  116. /*---------------------------------------------------------------------*/
  117.  if (display_screens != 1 && !horizontal)
  118.    {
  119.     if (CURRENT_VIEW->position_status)
  120.       {
  121.        sprintf(buffer,"L=%-.1ld C=%-.1d S=%-.1ld A=%d,%d",
  122.                       line_number,x,
  123.                       CURRENT_FILE->number_lines,
  124.                       CURRENT_FILE->autosave_alt,
  125.                       CURRENT_FILE->save_alt);
  126.       }
  127.     else
  128.       {
  129.        sprintf(buffer,"S=%-.1ld A=%d,%d",
  130.                       CURRENT_FILE->number_lines,
  131.                       CURRENT_FILE->autosave_alt,
  132.                       CURRENT_FILE->save_alt);
  133.       }
  134.     max_name = (CURRENT_SCREEN.screen_cols-1) - strlen(buffer);
  135.    }
  136.  else
  137.    {
  138.     if (CURRENT_VIEW->position_status)
  139.        max_name = (CURRENT_SCREEN.screen_cols-48);
  140.     else
  141.        max_name = (CURRENT_SCREEN.screen_cols-27);
  142.    }
  143. /*---------------------------------------------------------------------*/
  144. /* Determine which portion of filename can be displayed.               */
  145. /*---------------------------------------------------------------------*/
  146.  strcpy(display_path,CURRENT_FILE->fpath);
  147.  strcat(display_path,CURRENT_FILE->fname);
  148.  fpath = strtrans(display_path,ISLASH,ESLASH);
  149.  fpath_len = strlen(fpath);
  150.  if (fpath_len > max_name)
  151.    {
  152.     num_to_delete = fpath_len - max_name + 2;
  153.     num_to_start = (strlen(fpath)/2)-(num_to_delete/2);
  154.     for (i=0;i<num_to_start;i++)
  155.       {
  156.        mvwaddch(CURRENT_WINDOW_IDLINE,0,i,display_path[i]);
  157.       }
  158.     col = i+2;
  159.     waddstr(CURRENT_WINDOW_IDLINE,"<>");
  160.     for (i=num_to_start+num_to_delete;i<strlen(fpath);i++,col++)
  161.       {
  162.        mvwaddch(CURRENT_WINDOW_IDLINE,0,col,display_path[i]);
  163.       }
  164.    }
  165.  else
  166.   {
  167.    wmove(CURRENT_WINDOW_IDLINE,0,0);
  168.    wprintw(CURRENT_WINDOW_IDLINE,"%s",fpath);
  169.   }
  170.  if (display_screens != 1 && !horizontal)
  171.    {
  172.     wmove(CURRENT_WINDOW_IDLINE,0,max_name+1);
  173.     wprintw(CURRENT_WINDOW_IDLINE,"%-s",buffer);
  174.    }
  175.  else
  176.    {
  177.     if (CURRENT_VIEW->position_status)
  178.       {
  179.        wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46);
  180.        wprintw(CURRENT_WINDOW_IDLINE,"Line=%-6.1ld Col=%-5.1d",line_number,x);
  181.       }
  182.     wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46+21);
  183.     wprintw(CURRENT_WINDOW_IDLINE,"Size=%-6.1ld",CURRENT_FILE->number_lines);
  184.     wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46+32);
  185.     wprintw(CURRENT_WINDOW_IDLINE,"Alt=          ");
  186.     wmove(CURRENT_WINDOW_IDLINE,0,CURRENT_SCREEN.screen_cols-46+36);
  187.     wprintw(CURRENT_WINDOW_IDLINE,"%d,%d",CURRENT_FILE->autosave_alt,
  188.                              CURRENT_FILE->save_alt);
  189.    }
  190. #ifdef MSWIN
  191.  Win31Scroll(x,line_number,CURRENT_FILE->number_lines,CURRENT_FILE->max_line_length);
  192. #endif
  193.  wnoutrefresh(CURRENT_WINDOW_IDLINE);
  194. #ifdef TRACE
  195.  trace_return();
  196. #endif
  197.  return;
  198. }
  199. /***********************************************************************/
  200. #ifdef PROTO
  201. void show_footing(void)
  202. #else
  203. void show_footing()
  204. #endif
  205. /***********************************************************************/
  206. {
  207. /*------------------------- external data -----------------------------*/
  208.  extern CHARTYPE *rec;
  209.  extern CHARTYPE *cmd_rec;
  210.  extern CHARTYPE *pre_rec;
  211.  extern bool ETMODEx;
  212.  extern CHARTYPE *the_version;
  213.  extern CHARTYPE *the_copyright;
  214.  extern bool CLOCKx;
  215.  extern bool HEXDISPLAYx;
  216.  extern bool INSERTMODEx;
  217.  extern CHARTYPE number_of_files;
  218.  extern WINDOW *foot;
  219.  extern bool colour_support;
  220.  extern bool initial;
  221.  extern bool rexx_support;
  222.  extern ROWTYPE STATUSLINEx;
  223. /*--------------------------- local data ------------------------------*/
  224.  register int i=0;
  225.  short y=0,x=0;
  226.  short key=0;
  227.  WINDOW *w=NULL;
  228.  time_t timer;
  229.  struct tm *tblock=NULL;
  230. /*--------------------------- processing ------------------------------*/
  231. #ifdef TRACE
  232.  trace_function("show.c:    show_footing");
  233. #endif
  234. /*---------------------------------------------------------------------*/
  235. /* If the status line is off, just exit...                             */
  236. /*---------------------------------------------------------------------*/
  237.  if (STATUSLINEx == 'O')
  238.    {
  239. #ifdef TRACE
  240.     trace_return();
  241. #endif
  242.     return;
  243.    }
  244. /*---------------------------------------------------------------------*/
  245. /* If GUI option set for status line...                                */
  246. /*---------------------------------------------------------------------*/
  247.  if (STATUSLINEx == 'G')
  248.    {
  249. #ifdef MSWIN
  250.    Show_GUI_footing();
  251. # ifdef TRACE
  252.     trace_return();
  253. # endif
  254.     return;
  255. #endif
  256.  
  257. #ifdef TRACE
  258.     trace_return();
  259. #endif
  260.     return;
  261.    }
  262.  w = CURRENT_WINDOW;
  263. /*---------------------------------------------------------------------*/
  264. /* Display THE version.                                                */
  265. /*---------------------------------------------------------------------*/
  266.  mvwaddstr(foot,0,0,"THE");
  267.  mvwaddstr(foot,0,4,the_version);
  268. /*---------------------------------------------------------------------*/
  269. /* Clear from files to clock position...                               */
  270. /*---------------------------------------------------------------------*/
  271.  for (i=11;i<53;i++)
  272.    {
  273.     wmove(foot,0,i);
  274.     waddch(foot,' ');
  275.    }
  276. /*---------------------------------------------------------------------*/
  277. /* Display number of files or copyright on startup.                    */
  278. /*---------------------------------------------------------------------*/
  279.  wmove(foot,0,11);
  280.  if (initial)
  281.    {
  282.     waddstr(foot,the_copyright);
  283.     initial = FALSE;
  284.    }
  285.  else
  286.     wprintw(foot,"Files=%d ",number_of_files);
  287. /*---------------------------------------------------------------------*/
  288. /* Display any pending prefix command warning                          */
  289. /*---------------------------------------------------------------------*/
  290.  if (CURRENT_FILE->first_ppc != NULL
  291.  &&  CURRENT_FILE->first_ppc->ppc_cmd_idx != (-1)
  292.  &&  CURRENT_FILE->first_ppc->ppc_cmd_idx != (-2))
  293.    {
  294.     wmove(foot,0,20);
  295.     wprintw(foot,"'%s' pending...",get_prefix_command(CURRENT_FILE->first_ppc->ppc_cmd_idx));
  296.    }
  297. /*---------------------------------------------------------------------*/
  298. /* Display CLOCK.                                                      */
  299. /*---------------------------------------------------------------------*/
  300.  if (CLOCKx)
  301.    {
  302.     timer = time(NULL);
  303.     tblock = localtime(&timer);
  304.     wmove(foot,0,53);
  305.  
  306.     wprintw(foot,"%2d:%02.2d%s",
  307.            (tblock->tm_hour > 12) ? (tblock->tm_hour-12) : (tblock->tm_hour),
  308.             tblock->tm_min,
  309.            (tblock->tm_hour >= 12) ? ("pm") : ("am"));
  310.    }
  311. /*---------------------------------------------------------------------*/
  312. /* Display HEXDISPLAY.                                                 */
  313. /*---------------------------------------------------------------------*/
  314.  if (HEXDISPLAYx)
  315.    {
  316.     getyx(CURRENT_WINDOW,y,x);
  317.     switch(CURRENT_VIEW->current_window)
  318.       {
  319.        case WINDOW_MAIN:
  320.             key = (short)(*(rec+CURRENT_VIEW->verify_col-1+x) & A_CHARTEXT);
  321.             break;
  322.        case WINDOW_COMMAND:
  323.             key = (short)(*(cmd_rec+x) & A_CHARTEXT);
  324.             break;
  325.        case WINDOW_PREFIX:
  326.             key = (short)(*(pre_rec+x) & A_CHARTEXT);
  327.             break;
  328.       }
  329.     wmove(foot,0,61);
  330.     if (key == '\0')
  331.        wprintw(foot,"' '=00/000 ");
  332.     else
  333.       {
  334.        if (ETMODEx)
  335.           wprintw(foot,"'%1.1c'=%2.2X/%3.3d ",key,key,key);
  336.        else
  337.           wprintw(foot,"'%s'=%2.2X/%3.3d ",(key >127) ? " " : unctrl(key),key,key);
  338.       }
  339.    }
  340. /*---------------------------------------------------------------------*/
  341. /* Display colour setting.                                             */
  342. /*---------------------------------------------------------------------*/
  343.  wmove(foot,0,73);
  344. #ifdef A_COLOR
  345.  if (colour_support)
  346.     waddch(foot,'C');
  347.  else
  348.     waddch(foot,'c');
  349. #else
  350.  waddch(foot,'M');
  351. #endif
  352. /*---------------------------------------------------------------------*/
  353. /* Display REXX support character.                                     */
  354. /*---------------------------------------------------------------------*/
  355.  wmove(foot,0,74);
  356.  if (rexx_support)
  357.     waddch(foot,'R');
  358.  else
  359.     waddch(foot,' ');
  360. /*---------------------------------------------------------------------*/
  361. /* Display INSERTMODE toggle.                                          */
  362. /*---------------------------------------------------------------------*/
  363.  wmove(foot,0,76);
  364.  if (INSERTMODEx)
  365.     waddstr(foot,"Ins");
  366.  else
  367.     waddstr(foot,"   ");
  368. /*---------------------------------------------------------------------*/
  369. /* Refresh the STATUS LINE.                                            */
  370. /*---------------------------------------------------------------------*/
  371.  wnoutrefresh(foot);
  372. #ifdef TRACE
  373.  trace_return();
  374. #endif
  375.  return;
  376. }
  377. /***********************************************************************/
  378. #ifdef PROTO
  379. void clear_footing(void)
  380. #else
  381. void clear_footing()
  382. #endif
  383. /***********************************************************************/
  384. {
  385. /*------------------------- external data -----------------------------*/
  386.  extern WINDOW *foot;
  387.  extern ROWTYPE STATUSLINEx;
  388. /*--------------------------- local data ------------------------------*/
  389. /*--------------------------- processing ------------------------------*/
  390. #ifdef TRACE
  391.  trace_function("show.c:    clear_footing");
  392. #endif
  393. /*---------------------------------------------------------------------*/
  394. /* If the status line is not displayed, don't do anything.             */
  395. /*---------------------------------------------------------------------*/
  396.  switch(STATUSLINEx)
  397.    {
  398.     case 'T':
  399.     case 'B':
  400.          wmove(foot,0,0);
  401.          my_wclrtoeol(foot);
  402.          break;
  403.     default:
  404.          break;
  405.    }
  406. #ifdef TRACE
  407.  trace_return();
  408. #endif
  409.  return;
  410. }
  411. /***********************************************************************/
  412. #ifdef PROTO
  413. void redraw_window(WINDOW *win)
  414. #else
  415. void redraw_window(win)
  416. WINDOW *win;
  417. #endif
  418. /***********************************************************************/
  419. {
  420. /*------------------------- external data -----------------------------*/
  421. /*--------------------------- local data ------------------------------*/
  422.  register short i=0,j=0;
  423.  chtype ch=0;
  424.  short y=0,x=0;
  425. /*--------------------------- processing ------------------------------*/
  426. #ifdef TRACE
  427.  trace_function("show.c:    redraw_window");
  428. #endif
  429.  getyx(win,y,x);
  430.  for (i=0;i<getmaxx(win);i++)
  431.      for (j=0;j<getmaxy(win);j++)
  432.         {
  433.          wmove(win,j,i);
  434.          ch = (chtype)(winch(win) & A_CHARTEXT);
  435.          put_char(win,ch,ADDCHAR);
  436.         }
  437.  wmove(win,y,x);
  438. #ifdef TRACE
  439.  trace_return();
  440. #endif
  441.  return;
  442. }
  443. /***********************************************************************/
  444. #ifdef PROTO
  445. void repaint_screen(void)
  446. #else
  447. void repaint_screen()
  448. #endif
  449. /***********************************************************************/
  450. {
  451. /*-------------------------- external data ----------------------------*/
  452. /*--------------------------- local data ------------------------------*/
  453.  short y=0,x=0;
  454. /*--------------------------- processing ------------------------------*/
  455. #ifdef TRACE
  456.  trace_function("show.c:    repaint_screen");
  457. #endif
  458.  
  459.  getyx(CURRENT_WINDOW,y,x);
  460.  y = get_row_for_focus_line(CURRENT_VIEW->focus_line,
  461.                             CURRENT_VIEW->current_row);
  462.  if (x > CURRENT_SCREEN.cols[WINDOW_MAIN])
  463.     x = 0;
  464.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  465.  build_current_screen();
  466.  display_current_screen();
  467.  cleanup_command_line();
  468. /* show_heading();*/
  469.  wmove(CURRENT_WINDOW,y,x);
  470.  
  471. #ifdef TRACE
  472.  trace_return();
  473. #endif
  474.  return;
  475. }
  476. /***********************************************************************/
  477. #ifdef PROTO
  478. void build_current_screen(void)
  479. #else
  480. void build_current_screen()
  481. #endif
  482. /***********************************************************************/
  483. {
  484. /*-------------------------- external data ----------------------------*/
  485. /*--------------------------- local data ------------------------------*/
  486.  LINE *curr=NULL;
  487.  LINE *save_curr=NULL;
  488.  short crow = CURRENT_VIEW->current_row;
  489.  LINETYPE cline = CURRENT_VIEW->current_line;
  490. /*--------------------------- processing ------------------------------*/
  491. #ifdef TRACE
  492.  trace_function("show.c:    build_current_screen");
  493. #endif
  494.  hexshow_curr = save_curr = curr = lll_find(CURRENT_FILE->first_line,cline);
  495. /*---------------------------------------------------------------------*/
  496. /* Build   the file contents from the current line to the bottom of the*/
  497. /* window.                                                             */
  498. /*---------------------------------------------------------------------*/
  499.  build_lines(DIRECTION_FORWARD,curr,CURRENT_SCREEN.rows[WINDOW_MAIN]-crow,crow);
  500. /*---------------------------------------------------------------------*/
  501. /* Build   the file contents from the current line to the top of the   */
  502. /* window.                                                             */
  503. /*---------------------------------------------------------------------*/
  504.  curr = save_curr->prev;
  505.  build_lines(DIRECTION_BACKWARD,curr,crow,crow-1);
  506. #ifdef TRACE
  507.  trace_return();
  508. #endif
  509.  return;
  510. }
  511. /***********************************************************************/
  512. #ifdef PROTO
  513. void build_other_screen(void)
  514. #else
  515. void build_other_screen()
  516. #endif
  517. /***********************************************************************/
  518. {
  519. /*-------------------------- external data ----------------------------*/
  520. /*--------------------------- local data ------------------------------*/
  521.  CHARTYPE save_current_screen=0;
  522.  VIEW_DETAILS *save_current_view=NULL;
  523. /*--------------------------- processing ------------------------------*/
  524. #ifdef TRACE
  525.  trace_function("show.c:    build_other_screen");
  526. #endif
  527.  save_current_view = CURRENT_SCREEN.screen_view;
  528.  save_current_screen = current_screen;
  529.  CURRENT_VIEW  = OTHER_SCREEN.screen_view;
  530.  current_screen = (current_screen==0)?1:0;
  531.  build_current_screen();
  532.  current_screen = save_current_screen;
  533.  CURRENT_VIEW = save_current_view;
  534. #ifdef TRACE
  535.  trace_return();
  536. #endif
  537.  return;
  538. }
  539. /***********************************************************************/
  540. #ifdef PROTO
  541. void display_current_screen(void)
  542. #else
  543. void display_current_screen()
  544. #endif
  545. /***********************************************************************/
  546. {
  547. /*-------------------------- external data ----------------------------*/
  548.  extern bool in_macro;
  549.  extern bool in_profile;
  550.  extern bool curses_started;
  551. /*--------------------------- local data ------------------------------*/
  552.  WINDOW *previous_window;
  553.  unsigned short x=0,y=0;
  554.  unsigned short savex=0,savey=0;
  555. /*--------------------------- processing ------------------------------*/
  556. #ifdef TRACE
  557.  trace_function("show.c:    display_current_screen");
  558. #endif
  559. /*---------------------------------------------------------------------*/
  560. /* We don't display the screen if we are in a macro, in the profile or */
  561. /* curses hasn't started yet...                                        */
  562. /*---------------------------------------------------------------------*/
  563.  if (in_profile
  564.  || in_macro
  565.  || !curses_started)
  566.    {
  567. #ifdef TRACE
  568.     trace_return();
  569. #endif
  570.     return;
  571.    }
  572. /*---------------------------------------------------------------------*/
  573. /* Turn off the cursor.                                                */
  574. /*---------------------------------------------------------------------*/
  575.  draw_cursor(FALSE);
  576. /*---------------------------------------------------------------------*/
  577. /* Display the IDLINE window...                                        */
  578. /*---------------------------------------------------------------------*/
  579.  show_heading();
  580. /*---------------------------------------------------------------------*/
  581. /* Display the ARROW and CMDLINE if on...                              */
  582. /*---------------------------------------------------------------------*/
  583.  if (CURRENT_WINDOW_COMMAND != NULL)
  584.    {
  585.     wattrset(CURRENT_WINDOW_COMMAND,set_colour(CURRENT_FILE->attr+ATTR_CMDLINE));
  586.     redraw_window(CURRENT_WINDOW_COMMAND);
  587.     touchwin(CURRENT_WINDOW_COMMAND);
  588.     wnoutrefresh(CURRENT_WINDOW_COMMAND);
  589.    }
  590.  if (CURRENT_WINDOW_ARROW != NULL)
  591.    {
  592.     wattrset(CURRENT_WINDOW_ARROW,set_colour(CURRENT_FILE->attr+ATTR_ARROW));
  593.     redraw_window(CURRENT_WINDOW_ARROW);
  594.     touchwin(CURRENT_WINDOW_ARROW);
  595.     wnoutrefresh(CURRENT_WINDOW_ARROW);
  596.    }
  597. /*---------------------------------------------------------------------*/
  598. /* Save the position of previous window if on command line.            */
  599. /*---------------------------------------------------------------------*/
  600.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  601.     getyx(PREVIOUS_WINDOW,savey,savex);
  602.  getyx(CURRENT_WINDOW,y,x);
  603. /*---------------------------------------------------------------------*/
  604. /* Display the built lines...                                          */
  605. /*---------------------------------------------------------------------*/
  606.  show_lines();
  607. /*---------------------------------------------------------------------*/
  608. /* Refresh the windows.                                                */
  609. /*---------------------------------------------------------------------*/
  610.  if (CURRENT_WINDOW_PREFIX != NULL)
  611.      wnoutrefresh(CURRENT_WINDOW_PREFIX);
  612.  wrefresh(CURRENT_WINDOW_MAIN);
  613. /*---------------------------------------------------------------------*/
  614. /* Lastly, turn the cursor back on again.                              */
  615. /*---------------------------------------------------------------------*/
  616.  draw_cursor(TRUE);
  617. /*---------------------------------------------------------------------*/
  618. /* Restore the position of previous window if on command line.         */
  619. /*---------------------------------------------------------------------*/
  620.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  621.     wmove(PREVIOUS_WINDOW,savey,savex);
  622.  wmove(CURRENT_WINDOW,y,x);
  623. #ifdef TRACE
  624.  trace_return();
  625. #endif
  626.  return;
  627. }
  628. /***********************************************************************/
  629. #ifdef PROTO
  630. void display_other_screen(void)
  631. #else
  632. void display_other_screen()
  633. #endif
  634. /***********************************************************************/
  635. {
  636. /*-------------------------- external data ----------------------------*/
  637. /*--------------------------- local data ------------------------------*/
  638.  CHARTYPE save_current_screen=0;
  639.  VIEW_DETAILS *save_current_view=NULL;
  640. /*--------------------------- processing ------------------------------*/
  641. #ifdef TRACE
  642.  trace_function("show.c:    display_other_screen");
  643. #endif
  644.  save_current_view = CURRENT_SCREEN.screen_view;
  645.  save_current_screen = current_screen;
  646.  CURRENT_VIEW  = OTHER_SCREEN.screen_view;
  647.  current_screen = (current_screen==0)?1:0;
  648.  display_current_screen();
  649.  current_screen = save_current_screen;
  650.  CURRENT_VIEW = save_current_view;
  651. #ifdef TRACE
  652.  trace_return();
  653. #endif
  654.  return;
  655. }
  656. /***********************************************************************/
  657. #ifdef PROTO
  658. static void build_lines(short direction,LINE *curr,
  659.                          short rows,short start_row)
  660. #else
  661. static void build_lines(direction,curr,rows,start_row)
  662. short direction;
  663. LINE *curr;
  664. short rows,start_row;
  665. #endif
  666. /***********************************************************************/
  667. {
  668. /*-------------------------- external data ----------------------------*/
  669.  extern CHARTYPE *rec;
  670.  extern LENGTHTYPE rec_len;
  671.  extern VIEW_DETAILS *vd_mark;
  672.  extern short compatible;
  673. /*--------------------------- local data ------------------------------*/
  674.  LINETYPE cline = CURRENT_VIEW->current_line;
  675.  RESERVED *curr_rsrvd=NULL;
  676.  short num_shadow_lines=0;
  677.  bool marked=FALSE,current=FALSE;
  678.  short tab_actual_row=0;
  679.  short scale_actual_row=0;
  680.  short hexshow_actual_start_row=0;
  681. /*--------------------------- processing ------------------------------*/
  682. #ifdef TRACE
  683.  trace_function("show.c:    build_lines");
  684. #endif
  685. /*---------------------------------------------------------------------*/
  686. /* Determine the row that is the focus line.                           */
  687. /*---------------------------------------------------------------------*/
  688.  if (direction == DIRECTION_BACKWARD)
  689.     cline--;
  690.  num_shadow_lines = 0;
  691.  while(rows)
  692.    {
  693.     CURRENT_SCREEN.sl[start_row].full_length = FALSE;
  694.     CURRENT_SCREEN.sl[start_row].number_lines_excluded = 0;
  695.     CURRENT_SCREEN.sl[start_row].other_start_col = 0;
  696.     CURRENT_SCREEN.sl[start_row].other_end_col = 0;
  697.     CURRENT_SCREEN.sl[start_row].line_type = LINE_LINE;
  698.     CURRENT_SCREEN.sl[start_row].main_enterable = TRUE;
  699.     CURRENT_SCREEN.sl[start_row].prefix_enterable = TRUE;
  700. /*---------------------------------------------------------------------*/
  701. /* If HEXSHOW is ON...                                                 */
  702. /*---------------------------------------------------------------------*/
  703.     if (CURRENT_VIEW->hexshow_on)
  704.       {
  705.        hexshow_actual_start_row=calculate_actual_row(CURRENT_VIEW->hexshow_base,CURRENT_VIEW->hexshow_off,CURRENT_SCREEN.rows[WINDOW_MAIN]);
  706.        if (hexshow_actual_start_row == start_row
  707.        ||  hexshow_actual_start_row+1 == start_row)
  708.          {
  709.           LINETYPE line_length;
  710.           LINE *line_ptr;
  711.           CURRENT_SCREEN.sl[start_row].line_type = LINE_HEXSHOW;
  712.           CURRENT_SCREEN.sl[start_row].full_length = TRUE;
  713.           CURRENT_SCREEN.sl[start_row].line_number = (-1L);
  714.           CURRENT_SCREEN.sl[start_row].main_enterable = FALSE;
  715.           CURRENT_SCREEN.sl[start_row].prefix_enterable = FALSE;
  716.           CURRENT_SCREEN.sl[start_row].normal_colour = set_colour(CURRENT_FILE->attr+ATTR_SHADOW);
  717.           if (CURRENT_VIEW->current_line == CURRENT_VIEW->focus_line)
  718.             {
  719.              CURRENT_SCREEN.sl[start_row].contents = rec;
  720.              CURRENT_SCREEN.sl[start_row].length = rec_len;
  721.             }
  722.           else
  723.             {
  724.              CURRENT_SCREEN.sl[start_row].contents = hexshow_curr->line;
  725.              CURRENT_SCREEN.sl[start_row].length = hexshow_curr->length;
  726.             }
  727.           if (hexshow_actual_start_row == start_row)
  728.              CURRENT_SCREEN.sl[start_row].other_start_col = 0;
  729.           else
  730.              CURRENT_SCREEN.sl[start_row].other_start_col = 1;
  731.           if (CURRENT_VIEW->prefix) /* display prefix if on */
  732.             {
  733.              memset(CURRENT_SCREEN.sl[start_row].prefix,' ',PREFIX_WIDTH);
  734.              CURRENT_SCREEN.sl[start_row].prefix[PREFIX_WIDTH] = '\0';
  735.              CURRENT_SCREEN.sl[start_row].prefix_colour = set_colour(CURRENT_FILE->attr+ATTR_PREFIX);
  736.             }
  737.           start_row += direction;
  738.           rows--;
  739.           continue;
  740.          }
  741.       }
  742. /*---------------------------------------------------------------------*/
  743. /* If the current line is a reserved line...                           */
  744. /*---------------------------------------------------------------------*/
  745.     if ((curr_rsrvd = find_reserved_line(TRUE,start_row,0,0)) != NULL)
  746.       {
  747.        CURRENT_SCREEN.sl[start_row].line_type = LINE_RESERVED;
  748.        CURRENT_SCREEN.sl[start_row].full_length = TRUE;
  749.        CURRENT_SCREEN.sl[start_row].line_number = (-1L);
  750.        CURRENT_SCREEN.sl[start_row].current = (LINE *)NULL;
  751.        CURRENT_SCREEN.sl[start_row].main_enterable = FALSE;
  752.        CURRENT_SCREEN.sl[start_row].prefix_enterable = FALSE;
  753.        if (CURRENT_VIEW->prefix)               /* display prefix if on */
  754.          {
  755.           CURRENT_SCREEN.sl[start_row].prefix_colour = set_colour(curr_rsrvd->attr);
  756.           if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_LEFT)
  757.             {
  758.              memset(CURRENT_SCREEN.sl[start_row].prefix,' ',PREFIX_WIDTH);
  759.              memcpy(CURRENT_SCREEN.sl[start_row].prefix,curr_rsrvd->line,min(curr_rsrvd->length,PREFIX_WIDTH));
  760.              CURRENT_SCREEN.sl[start_row].prefix[PREFIX_WIDTH] = '\0';
  761.              if (curr_rsrvd->length <= PREFIX_WIDTH)
  762.                {
  763.                 CURRENT_SCREEN.sl[start_row].contents = NULL;
  764.                 CURRENT_SCREEN.sl[start_row].length = 0;
  765.                }
  766.              else
  767.                {
  768.                 CURRENT_SCREEN.sl[start_row].contents = curr_rsrvd->line+PREFIX_WIDTH;
  769.                 CURRENT_SCREEN.sl[start_row].length = curr_rsrvd->length-PREFIX_WIDTH;
  770.                }
  771.             }
  772.           else
  773.             {
  774.              CURRENT_SCREEN.sl[start_row].contents = curr_rsrvd->line;
  775.              CURRENT_SCREEN.sl[start_row].length = min(curr_rsrvd->length,CURRENT_SCREEN.rows[WINDOW_MAIN]);
  776.              if (curr_rsrvd->length < CURRENT_SCREEN.rows[WINDOW_MAIN])
  777.                {
  778.                 memset(CURRENT_SCREEN.sl[start_row].prefix,' ',PREFIX_WIDTH);
  779.                 CURRENT_SCREEN.sl[start_row].prefix[PREFIX_WIDTH] = '\0';
  780.                }
  781.              else
  782.                {
  783.                 memcpy(CURRENT_SCREEN.sl[start_row].prefix,curr_rsrvd->line+CURRENT_SCREEN.rows[WINDOW_MAIN],min(curr->length-CURRENT_SCREEN.rows[WINDOW_MAIN],PREFIX_WIDTH));
  784.                }
  785.             }
  786.          }
  787.        else
  788.          {
  789.           CURRENT_SCREEN.sl[start_row].contents = curr_rsrvd->line;
  790.           CURRENT_SCREEN.sl[start_row].length = curr_rsrvd->length;
  791.          }
  792.        CURRENT_SCREEN.sl[start_row].normal_colour = set_colour(curr_rsrvd->attr);
  793.        CURRENT_SCREEN.sl[start_row].other_colour = set_colour(curr_rsrvd->attr);
  794.        start_row += direction;
  795.        rows--;
  796.        continue;
  797.       }
  798. /*---------------------------------------------------------------------*/
  799. /* If the current line is the scale or tab line...                     */
  800. /*---------------------------------------------------------------------*/
  801.     tab_actual_row=calculate_actual_row(CURRENT_VIEW->tab_base,CURRENT_VIEW->tab_off,CURRENT_SCREEN.rows[WINDOW_MAIN]);
  802.     scale_actual_row=calculate_actual_row(CURRENT_VIEW->scale_base,CURRENT_VIEW->scale_off,CURRENT_SCREEN.rows[WINDOW_MAIN]);
  803.     if ((CURRENT_VIEW->scale_on && scale_actual_row == start_row)
  804.     || (CURRENT_VIEW->tab_on && tab_actual_row == start_row))
  805.       {
  806.        CURRENT_SCREEN.sl[start_row].contents = NULL;
  807.        CURRENT_SCREEN.sl[start_row].length = 0;
  808.        CURRENT_SCREEN.sl[start_row].line_number = (-1L);
  809.        CURRENT_SCREEN.sl[start_row].current = (LINE *)NULL;
  810.        CURRENT_SCREEN.sl[start_row].main_enterable = FALSE;
  811.        CURRENT_SCREEN.sl[start_row].prefix_enterable = FALSE;
  812.        if (CURRENT_VIEW->prefix) /* display prefix if on */
  813.          {
  814.           memset(CURRENT_SCREEN.sl[start_row].prefix,' ',PREFIX_WIDTH);
  815.           CURRENT_SCREEN.sl[start_row].prefix[PREFIX_WIDTH] = '\0';
  816.           CURRENT_SCREEN.sl[start_row].prefix_colour = set_colour(CURRENT_FILE->attr+ATTR_PREFIX);
  817.          }
  818.        if (CURRENT_VIEW->tab_on && tab_actual_row == start_row)
  819.          {
  820.           CURRENT_SCREEN.sl[start_row].line_type |= LINE_TABLINE;
  821.           CURRENT_SCREEN.sl[start_row].normal_colour = set_colour(CURRENT_FILE->attr+ATTR_TABLINE);
  822.          }
  823.        if (CURRENT_VIEW->scale_on && scale_actual_row == start_row)
  824.          {
  825.           CURRENT_SCREEN.sl[start_row].line_type |= LINE_SCALE;
  826.           CURRENT_SCREEN.sl[start_row].normal_colour = set_colour(CURRENT_FILE->attr+ATTR_SCALE);
  827.          }
  828.        start_row += direction;
  829.        rows--;
  830.        continue;
  831.       }
  832. /*---------------------------------------------------------------------*/
  833. /* If the current line is above or below TOF or EOF, set all to blank. */
  834. /*---------------------------------------------------------------------*/
  835.     if (curr == NULL)
  836.       {
  837.        CURRENT_SCREEN.sl[start_row].contents = NULL;
  838.        CURRENT_SCREEN.sl[start_row].length = 0;
  839.        CURRENT_SCREEN.sl[start_row].normal_colour = set_colour(CURRENT_FILE->attr+ATTR_FILEAREA);
  840.        CURRENT_SCREEN.sl[start_row].line_type = (direction == DIRECTION_BACKWARD) ? LINE_OUT_OF_BOUNDS_ABOVE : LINE_OUT_OF_BOUNDS_BELOW;
  841.        CURRENT_SCREEN.sl[start_row].line_number = (-1L);
  842.        CURRENT_SCREEN.sl[start_row].current = (LINE *)NULL;
  843.        CURRENT_SCREEN.sl[start_row].main_enterable = FALSE;
  844.        CURRENT_SCREEN.sl[start_row].prefix_enterable = FALSE;
  845.        if (CURRENT_VIEW->prefix) /* display prefix if on */
  846.          {
  847.           memset(CURRENT_SCREEN.sl[start_row].prefix,' ',PREFIX_WIDTH);
  848.           CURRENT_SCREEN.sl[start_row].prefix[PREFIX_WIDTH] = '\0';
  849.           CURRENT_SCREEN.sl[start_row].prefix_colour = set_colour(CURRENT_FILE->attr+ATTR_PREFIX);
  850.          }
  851.        start_row += direction;
  852.        rows--;
  853.        continue;
  854.       }
  855. /*---------------------------------------------------------------------*/
  856. /* If the current line is excluded, increment a running total.         */
  857. /* Ignore the line if on TOF or BOF.                                   */
  858. /*---------------------------------------------------------------------*/
  859.     if (curr->next != NULL                           /* Bottom of file */
  860.     &&  curr->prev != NULL)                             /* Top of file */
  861.       {
  862.        if (in_scope(curr)
  863.        || cline == CURRENT_VIEW->current_line
  864.        || curr->pre != NULL)
  865.           ;
  866.        else
  867.          {
  868.           if (num_shadow_lines == 0
  869.           && direction == DIRECTION_FORWARD)
  870.             {
  871.              set_prefix_contents(curr,start_row,cline);
  872.              CURRENT_SCREEN.sl[start_row].line_number = cline;
  873.              CURRENT_SCREEN.sl[start_row].current = curr;
  874.             }
  875.           num_shadow_lines++;
  876.           cline += (LINETYPE)direction;
  877.           if (direction == DIRECTION_FORWARD)
  878.              curr = curr->next;
  879.           else
  880.              curr = curr->prev;
  881.           continue;
  882.          }
  883.       }
  884. /*---------------------------------------------------------------------*/
  885. /* If we get here, we have to determine if a shadow line is to be      */
  886. /* displayed or not.                                                   */
  887. /*---------------------------------------------------------------------*/
  888.     if (CURRENT_VIEW->shadow
  889.     && num_shadow_lines > 0)
  890.       {
  891.        CURRENT_SCREEN.sl[start_row].length = 0;
  892.        if (direction != DIRECTION_FORWARD)
  893.          {
  894.           set_prefix_contents(curr->next,start_row,cline+1);
  895.           CURRENT_SCREEN.sl[start_row].line_number = cline+1;
  896.           CURRENT_SCREEN.sl[start_row].current = curr;
  897.          }
  898.        CURRENT_SCREEN.sl[start_row].normal_colour = set_colour(CURRENT_FILE->attr+ATTR_SHADOW);
  899.        CURRENT_SCREEN.sl[start_row].full_length = TRUE;
  900.        CURRENT_SCREEN.sl[start_row].number_lines_excluded = num_shadow_lines;
  901.        CURRENT_SCREEN.sl[start_row].line_type = LINE_SHADOW;
  902.        if (compatible == COMPAT_XEDIT)
  903.           CURRENT_SCREEN.sl[start_row].main_enterable = FALSE;
  904.        num_shadow_lines = 0;
  905.        start_row += direction;
  906.        rows--;
  907.        continue;
  908.       }
  909. /*---------------------------------------------------------------------*/
  910. /* Determine if line being processed is the current line.              */
  911. /*---------------------------------------------------------------------*/
  912.     if (cline == CURRENT_VIEW->current_line)
  913.        current = TRUE;
  914.     else
  915.        current = FALSE;
  916. /*---------------------------------------------------------------------*/
  917. /* Determine if line being processed is in a marked block.             */
  918. /*---------------------------------------------------------------------*/
  919.     if (MARK_VIEW != (VIEW_DETAILS *)NULL
  920.     &&  MARK_VIEW == CURRENT_VIEW)
  921.       {
  922.        if (cline >= MARK_VIEW->mark_start_line
  923.        &&  cline <= MARK_VIEW->mark_end_line)
  924.           marked = TRUE;
  925.        else
  926.           marked = FALSE;
  927.       }
  928. /*---------------------------------------------------------------------*/
  929. /* The remainder is for lines that are to be displayed.                */
  930. /*---------------------------------------------------------------------*/
  931.     CURRENT_SCREEN.sl[start_row].line_number = cline;
  932.     CURRENT_SCREEN.sl[start_row].current = curr;
  933. /*---------------------------------------------------------------------*/
  934. /* If the current row to be displayed is the focus line, display       */
  935. /* the working area, rec and rec_len instead of the entry in the LL.   */
  936. /*---------------------------------------------------------------------*/
  937.     if (cline == CURRENT_VIEW->focus_line)
  938.       {
  939.        CURRENT_SCREEN.sl[start_row].contents = rec;
  940.        CURRENT_SCREEN.sl[start_row].length = rec_len;
  941.       }
  942.     else
  943.       {
  944.        CURRENT_SCREEN.sl[start_row].contents = curr->line;
  945.        CURRENT_SCREEN.sl[start_row].length = curr->length;
  946.       }
  947.     set_prefix_contents(curr,start_row,cline);
  948. /*---------------------------------------------------------------------*/
  949. /* Set up TOF and EOF lines...                                         */
  950. /*---------------------------------------------------------------------*/
  951.     if (curr->next == NULL                           /* Bottom of file */
  952.     ||  curr->prev == NULL)                             /* Top of file */
  953.       {
  954.        CURRENT_SCREEN.sl[start_row].normal_colour = (current) ? set_colour(CURRENT_FILE->attr+ATTR_CTOFEOF) :
  955.                                                    set_colour(CURRENT_FILE->attr+ATTR_TOFEOF);
  956.        CURRENT_SCREEN.sl[start_row].line_type = LINE_TOF_EOF;
  957.        if (compatible == COMPAT_XEDIT)
  958.           CURRENT_SCREEN.sl[start_row].main_enterable = FALSE;
  959.       }
  960.     else
  961.       {
  962.        if (marked)
  963.          {
  964.           switch(MARK_VIEW->mark_type)
  965.             {
  966.              case M_LINE:
  967.                   CURRENT_SCREEN.sl[start_row].other_start_col = (-1);
  968.                   CURRENT_SCREEN.sl[start_row].other_end_col = (-1);
  969.                   CURRENT_SCREEN.sl[start_row].normal_colour = (current) ? set_colour(CURRENT_FILE->attr+ATTR_CBLOCK) :
  970.                                                                set_colour(CURRENT_FILE->attr+ATTR_BLOCK);
  971.                   CURRENT_SCREEN.sl[start_row].full_length = TRUE;
  972.                   break;
  973.              case M_BOX:
  974.              case M_COLUMN:
  975.              case M_WORD:
  976.                   CURRENT_SCREEN.sl[start_row].other_start_col = MARK_VIEW->mark_start_col - 1;
  977.                   CURRENT_SCREEN.sl[start_row].other_end_col = MARK_VIEW->mark_end_col - 1;
  978.                   CURRENT_SCREEN.sl[start_row].normal_colour = (current) ? set_colour(CURRENT_FILE->attr+ATTR_CURLINE) :
  979.                                                                set_colour(CURRENT_FILE->attr+ATTR_FILEAREA);
  980.                   CURRENT_SCREEN.sl[start_row].other_colour = (current) ? set_colour(CURRENT_FILE->attr+ATTR_CBLOCK) :
  981.                                                               set_colour(CURRENT_FILE->attr+ATTR_BLOCK);
  982.                   break;
  983.              case M_STREAM:
  984.                   break;
  985.             }
  986.          }
  987.        else
  988.          {
  989.           CURRENT_SCREEN.sl[start_row].normal_colour = (current) ? set_colour(CURRENT_FILE->attr+ATTR_CURLINE) :
  990.                                                       set_colour(CURRENT_FILE->attr+ATTR_FILEAREA);
  991.           CURRENT_SCREEN.sl[start_row].other_colour = CURRENT_SCREEN.sl[start_row].normal_colour;
  992.          }
  993.       }
  994.     start_row += direction;
  995.     rows--;
  996.  
  997.     cline += (LINETYPE)direction;
  998.     if (direction == DIRECTION_FORWARD)
  999.        curr = curr->next;
  1000.     else
  1001.        curr = curr->prev;
  1002.    }
  1003. #ifdef TRACE
  1004.  trace_return();
  1005. #endif
  1006.  return;
  1007. }
  1008. /***********************************************************************/
  1009. #ifdef PROTO
  1010. static void show_lines(void)
  1011. #else
  1012. static void show_lines()
  1013. #endif
  1014. /***********************************************************************/
  1015. {
  1016. /*------------------------- external data -----------------------------*/
  1017.  extern bool ETMODEx;
  1018.  extern short prefix_width;
  1019. /*--------------------------- local data ------------------------------*/
  1020.  register short i=0,j=0;
  1021.  short true_col=0;
  1022.  short max_cols = min(CURRENT_SCREEN.cols[WINDOW_MAIN],CURRENT_VIEW->verify_end-CURRENT_VIEW->verify_start+1);
  1023.  short off=0,num_tens=0;
  1024.  unsigned short y=0,x=0;
  1025.  CHARTYPE tens[5];
  1026. /*--------------------------- processing ------------------------------*/
  1027. #ifdef TRACE
  1028.  trace_function("show.c:    show_lines");
  1029. #endif
  1030.  for (i=0;i<CURRENT_SCREEN.rows[WINDOW_MAIN];i++)
  1031.    {
  1032. /*---------------------------------------------------------------------*/
  1033. /* Display the contents of the prefix area (if on).                    */
  1034. /*---------------------------------------------------------------------*/
  1035.     if (CURRENT_VIEW->prefix)
  1036.       {
  1037.        wattrset(CURRENT_WINDOW_PREFIX,CURRENT_SCREEN.sl[i].prefix_colour);
  1038.        wmove(CURRENT_WINDOW_PREFIX,i,0);
  1039.        my_wclrtoeol(CURRENT_WINDOW_PREFIX);
  1040.        if (ETMODEx)
  1041.           waddstr(CURRENT_WINDOW_PREFIX,CURRENT_SCREEN.sl[i].prefix);
  1042.        else
  1043.           put_string(CURRENT_WINDOW_PREFIX,i,0,CURRENT_SCREEN.sl[i].prefix,strlen(CURRENT_SCREEN.sl[i].prefix));
  1044.       }
  1045.     wmove(CURRENT_WINDOW_MAIN,i,0);
  1046.     wattrset(CURRENT_WINDOW_MAIN,CURRENT_SCREEN.sl[i].normal_colour);
  1047. /*---------------------------------------------------------------------*/
  1048. /* Display any shadow line. No need to test to see if SHADOW is ON as  */
  1049. /* number_excluded_lines would not be > 0 if SHADOW OFF.               */
  1050. /*---------------------------------------------------------------------*/
  1051.     if (CURRENT_SCREEN.sl[i].number_lines_excluded > 0)
  1052.       {
  1053.        for (j=0;j<CURRENT_SCREEN.cols[WINDOW_MAIN];j++)
  1054.           mvwaddch(CURRENT_WINDOW_MAIN,i,j,'-');
  1055.        wmove(CURRENT_WINDOW_MAIN,i,max(0,(CURRENT_SCREEN.cols[WINDOW_MAIN]/2)-14));
  1056.        wprintw(CURRENT_WINDOW_MAIN,"%4d line(s) not displayed ",CURRENT_SCREEN.sl[i].number_lines_excluded);
  1057.        continue;
  1058.       }
  1059. /*---------------------------------------------------------------------*/
  1060. /* Display SCALE and/or TABLINE...                                     */
  1061. /*---------------------------------------------------------------------*/
  1062.     if (CURRENT_SCREEN.sl[i].line_type & LINE_SCALE
  1063.     ||  CURRENT_SCREEN.sl[i].line_type & LINE_TABLINE)
  1064.       {
  1065.        my_wclrtoeol(CURRENT_WINDOW_MAIN);
  1066.        for (j=0;j<max_cols;j++)
  1067.          {
  1068.           wmove(CURRENT_WINDOW_MAIN,i,j);
  1069.           true_col = j + CURRENT_VIEW->verify_col-1;
  1070. /*---------------------------------------------------------------------*/
  1071. /* Display 'T' in each tab column. This overrides all other characters.*/
  1072. /*---------------------------------------------------------------------*/
  1073.           if (CURRENT_SCREEN.sl[i].line_type & LINE_TABLINE)
  1074.             {
  1075.              if (is_tab_col(true_col+1))
  1076.                {
  1077.                 waddch(CURRENT_WINDOW_MAIN,'T');
  1078.                 continue;
  1079.                }
  1080.             }
  1081. /*---------------------------------------------------------------------*/
  1082. /* Only display the following if it is a scale line...                 */
  1083. /*---------------------------------------------------------------------*/
  1084.           if (CURRENT_SCREEN.sl[i].line_type & LINE_SCALE)
  1085.             {
  1086.              if (CURRENT_VIEW->margin_left-1 == true_col)
  1087.                {
  1088.                 waddch(CURRENT_WINDOW_MAIN,'[');
  1089.                 continue;
  1090.                }
  1091.              if (CURRENT_VIEW->margin_right-1 == true_col)
  1092.                {
  1093.                 waddch(CURRENT_WINDOW_MAIN,']');
  1094.                 continue;
  1095.                }
  1096.              if (CURRENT_VIEW->margin_indent_offset
  1097.              &&  CURRENT_VIEW->margin_left+CURRENT_VIEW->margin_indent-1 == true_col)
  1098.                {
  1099.                 waddch(CURRENT_WINDOW_MAIN,'p');
  1100.                 continue;
  1101.                }
  1102.              if (!CURRENT_VIEW->margin_indent_offset
  1103.              &&  CURRENT_VIEW->margin_indent-1 == true_col)
  1104.                {
  1105.                 waddch(CURRENT_WINDOW_MAIN,'p');
  1106.                 continue;
  1107.                }
  1108.              if (CURRENT_VIEW->zone_start-1 == true_col)
  1109.                {
  1110.                 waddch(CURRENT_WINDOW_MAIN,'<');
  1111.                 continue;
  1112.                }
  1113.              if (CURRENT_VIEW->zone_end-1 == true_col)
  1114.                {
  1115.                 waddch(CURRENT_WINDOW_MAIN,'>');
  1116.                 continue;
  1117.                }
  1118.              if (true_col % 10 == 9)
  1119.                {
  1120.                 sprintf(tens,"%d",(true_col / 10) + 1);
  1121.                 num_tens = strlen(tens);
  1122.                 getyx(CURRENT_WINDOW_MAIN,y,x);
  1123.                 if ((short)x-(num_tens-1) < 0)
  1124.                   {
  1125.                    off = -((short)x-(num_tens-1));
  1126.                    x = 0;
  1127.                   }
  1128.                 else
  1129.                   {
  1130.                    off = 0;
  1131.                    x -= (num_tens-1);
  1132.                   }
  1133.                 wmove(CURRENT_WINDOW_MAIN,y,x);
  1134.                 waddstr(CURRENT_WINDOW_MAIN,tens+off);
  1135.                 continue;
  1136.                }
  1137.              if (true_col % 5 == 4)
  1138.                {
  1139.                 waddch(CURRENT_WINDOW_MAIN,'+');
  1140.                 continue;
  1141.                }
  1142.             }
  1143.           waddch(CURRENT_WINDOW_MAIN,'.');
  1144.          }
  1145.        continue;
  1146.       }
  1147. /*---------------------------------------------------------------------*/
  1148. /* Display HEXSHOW line...                                             */
  1149. /*---------------------------------------------------------------------*/
  1150.     if (CURRENT_SCREEN.sl[i].line_type & LINE_HEXSHOW)
  1151.       {
  1152.        my_wclrtoeol(CURRENT_WINDOW_MAIN);
  1153.        show_hex_line(i);
  1154.        continue;
  1155.       }
  1156. /*---------------------------------------------------------------------*/
  1157. /* Display TOF or EOF line.                                            */
  1158. /*---------------------------------------------------------------------*/
  1159.     if (CURRENT_SCREEN.sl[i].line_type == LINE_TOF_EOF)
  1160.       {
  1161.        my_wclrtoeol(CURRENT_WINDOW_MAIN);
  1162.        waddstr(CURRENT_WINDOW_MAIN,CURRENT_SCREEN.sl[i].contents);
  1163.        continue;
  1164.       }
  1165. /*---------------------------------------------------------------------*/
  1166. /* Display marked LINE block line(s).                                  */
  1167. /*---------------------------------------------------------------------*/
  1168.     show_a_line(i);
  1169.    }
  1170.  if (CURRENT_WINDOW_PREFIX != NULL)
  1171.     wattrset(CURRENT_WINDOW_PREFIX,set_colour(CURRENT_FILE->attr+ATTR_PENDING));
  1172.  wattrset(CURRENT_WINDOW_MAIN,set_colour(CURRENT_FILE->attr+ATTR_FILEAREA));
  1173. #ifdef TRACE
  1174.  trace_return();
  1175. #endif
  1176.  return;
  1177. }
  1178. /***********************************************************************/
  1179. #ifdef PROTO
  1180. static void show_a_line(short row)
  1181. #else
  1182. static void show_a_line(row)
  1183. short row;
  1184. #endif
  1185. /***********************************************************************/
  1186. {
  1187. /*------------------------- external data -----------------------------*/
  1188. /*--------------------------- local data ------------------------------*/
  1189.  register short i=0;
  1190.  chtype ch=0;
  1191.  LENGTHTYPE vcol=0,vend=0,vlen=0;
  1192.  LENGTHTYPE length=0;
  1193.  CHARTYPE *line=NULL;
  1194. #if defined(USE_EXTCURSES)
  1195.  chtype attr=0,old_attr=0;
  1196. #endif
  1197. /*--------------------------- processing ------------------------------*/
  1198. #ifdef TRACE
  1199.  trace_function("show.c:    show_a_line");
  1200. #endif
  1201. /*---------------------------------------------------------------------*/
  1202. /* If the line to be displayed is a reserved line, set the columns to  */
  1203. /* be displayed so that the full line is displayed.                    */
  1204. /*---------------------------------------------------------------------*/
  1205.  if (CURRENT_SCREEN.sl[row].line_type == LINE_RESERVED)
  1206.    {
  1207.     vcol = 0;
  1208.     vend = CURRENT_SCREEN.cols[WINDOW_MAIN];
  1209.     vlen = CURRENT_SCREEN.cols[WINDOW_MAIN];
  1210.    }
  1211.  else
  1212.    {
  1213.     vcol = CURRENT_VIEW->verify_col - 1;
  1214.     vend = CURRENT_VIEW->verify_end - 1;
  1215.     vlen = CURRENT_VIEW->verify_end - CURRENT_VIEW->verify_start + 1;
  1216.    }
  1217.  length = CURRENT_SCREEN.sl[row].length;
  1218.  line = CURRENT_SCREEN.sl[row].contents;
  1219. /*---------------------------------------------------------------------*/
  1220. /* If the contents are NULL then clear to eol in normal colour.        */
  1221. /*---------------------------------------------------------------------*/
  1222.  if (line == NULL)
  1223.    {
  1224.     my_wclrtoeol(CURRENT_WINDOW_MAIN);
  1225. #ifdef TRACE
  1226.     trace_return();
  1227. #endif
  1228.     return;
  1229.    }
  1230.  wmove(CURRENT_WINDOW_MAIN,row,0);
  1231.  for (i=0;i<CURRENT_SCREEN.cols[WINDOW_MAIN];i++)
  1232.    {
  1233. /*---------------------------------------------------------------------*/
  1234. /* If the last character in the line has been displayed, display blank.*/
  1235. /*---------------------------------------------------------------------*/
  1236.     if (i+vcol < length)
  1237.        ch = *(line+i+vcol);
  1238.     else
  1239.        ch = ' ';
  1240. /*---------------------------------------------------------------------*/
  1241. /* Determine colour of character to be displayed. BOX blocks are sorted*/
  1242. /* out here.                                                           */
  1243. /*---------------------------------------------------------------------*/
  1244.     if (vcol+i >= CURRENT_SCREEN.sl[row].other_start_col
  1245.     &&  vcol+i <= CURRENT_SCREEN.sl[row].other_end_col)
  1246. #if defined(USE_EXTCURSES)
  1247.        attr = CURRENT_SCREEN.sl[row].other_colour;
  1248. #else
  1249.        ch = ch | CURRENT_SCREEN.sl[row].other_colour;
  1250. #endif
  1251.     else
  1252. #if defined(USE_EXTCURSES)
  1253.        attr = CURRENT_SCREEN.sl[row].normal_colour;
  1254. #else
  1255.        ch = ch | CURRENT_SCREEN.sl[row].normal_colour;
  1256. #endif
  1257. /*---------------------------------------------------------------------*/
  1258. /* If we have gone past the VERIFY END column, display a blank in the  */
  1259. /* normal colour.                                                      */
  1260. /*---------------------------------------------------------------------*/
  1261.     if (i >= vlen)
  1262.       {
  1263. #if defined(USE_EXTCURSES)
  1264.        ch = ' ';
  1265.        attr = CURRENT_SCREEN.sl[row].normal_colour;
  1266. #else
  1267.        ch = ' ' | CURRENT_SCREEN.sl[row].normal_colour;
  1268. #endif
  1269.       }
  1270. /*---------------------------------------------------------------------*/
  1271. /* Go and display the character...                                     */
  1272. /*---------------------------------------------------------------------*/
  1273. #if defined(USE_EXTCURSES)
  1274.     if (attr != old_attr)
  1275.       {
  1276.        wattrset(CURRENT_WINDOW_MAIN,attr);
  1277.        old_attr = attr;
  1278.       }
  1279. #endif
  1280.     put_char(CURRENT_WINDOW_MAIN,ch,ADDCHAR);
  1281.    }
  1282. #ifdef TRACE
  1283.  trace_return();
  1284. #endif
  1285.  return;
  1286. }
  1287. /***********************************************************************/
  1288. #ifdef PROTO
  1289. static void set_prefix_contents(LINE *curr,short start_row,LINETYPE cline)
  1290. #else
  1291. static void set_prefix_contents(curr,start_row,cline)
  1292. LINE *curr;
  1293. short start_row;
  1294. LINETYPE cline;
  1295. #endif
  1296. /***********************************************************************/
  1297. {
  1298. /*-------------------------- external data ----------------------------*/
  1299.  extern short prefix_width;
  1300. /*--------------------------- local data ------------------------------*/
  1301.  short offset=0;
  1302.  CHARTYPE *ptr=NULL;
  1303. /*--------------------------- processing ------------------------------*/
  1304. #ifdef TRACE
  1305.  trace_function("show.c:    set_prefix_contents");
  1306. #endif
  1307.  ptr = CURRENT_SCREEN.sl[start_row].prefix;
  1308. /*---------------------------------------------------------------------*/
  1309. /* Determine in which column we are to start displaying prefix contents*/
  1310. /*---------------------------------------------------------------------*/
  1311.  if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT
  1312.  &&  prefix_width != PREFIX_WIDTH)
  1313.    {
  1314.     offset = 1;
  1315.     *(ptr) = ' ';
  1316.    }
  1317.  else
  1318.     offset = 0;
  1319.  if (CURRENT_VIEW->prefix)
  1320.    {
  1321.     if (curr->pre != NULL)                /* prefix command pending... */
  1322. /*  && !blank_field(curr->pre->ppc_command))*/    /* ... and not blank */
  1323.       {
  1324.        strcpy(ptr+offset,curr->pre->ppc_command);
  1325.        CURRENT_SCREEN.sl[start_row].prefix_colour = set_colour(CURRENT_FILE->attr+ATTR_PENDING);
  1326.       }
  1327.     else                             /* no prefix command on this line */
  1328.       {
  1329.        memset(ptr,' ',PREFIX_WIDTH);
  1330.        CURRENT_SCREEN.sl[start_row].prefix[PREFIX_WIDTH] = '\0';
  1331.        CURRENT_SCREEN.sl[start_row].prefix_colour = set_colour(CURRENT_FILE->attr+ATTR_PREFIX);
  1332.        if (CURRENT_VIEW->number)
  1333.          {
  1334.           if ((CURRENT_VIEW->prefix&PREFIX_STATUS_MASK) == PREFIX_ON)
  1335.              sprintf(ptr+offset,"%*.*ld",prefix_width,prefix_width,cline);
  1336.           else
  1337.              sprintf(ptr+offset,"%*ld",prefix_width,cline);
  1338.          }
  1339.        else
  1340.          {
  1341.           if ((CURRENT_VIEW->prefix&PREFIX_STATUS_MASK) == PREFIX_ON)
  1342.              memset(ptr+offset,'=',prefix_width);
  1343.          }
  1344.       }
  1345.    }
  1346. #ifdef TRACE
  1347.  trace_return();
  1348. #endif
  1349.  return;
  1350. }
  1351. /***********************************************************************/
  1352. #ifdef PROTO
  1353. bool line_in_view(LINETYPE line_number)
  1354. #else
  1355. bool line_in_view(line_number)
  1356. LINETYPE line_number;
  1357. #endif
  1358. /***********************************************************************/
  1359. {
  1360. /*-------------------------- external data ----------------------------*/
  1361. /*--------------------------- local data ------------------------------*/
  1362.  register short i=0;
  1363.  bool result=FALSE;
  1364. /*--------------------------- processing ------------------------------*/
  1365. #ifdef TRACE
  1366.  trace_function("show.c:    line_in_view");
  1367. #endif
  1368.  for (i=0;i<CURRENT_SCREEN.rows[WINDOW_MAIN];i++)
  1369.    {
  1370.     if (CURRENT_SCREEN.sl[i].line_number == line_number)
  1371.       {
  1372.        result = TRUE;
  1373.        break;
  1374.       }
  1375.    }
  1376. #ifdef TRACE
  1377.  trace_return();
  1378. #endif
  1379.  return(result);
  1380. }
  1381. /***********************************************************************/
  1382. #ifdef PROTO
  1383. LINETYPE find_next_current_line(LINETYPE num_pages,short direction)
  1384. #else
  1385. LINETYPE find_next_current_line(num_pages,direction)
  1386. LINETYPE num_pages;
  1387. short direction;
  1388. #endif
  1389. /***********************************************************************/
  1390. {
  1391. /*-------------------------- external data ----------------------------*/
  1392. /*--------------------------- local data ------------------------------*/
  1393.  register short i=0;
  1394.  LINETYPE cline = CURRENT_VIEW->current_line;
  1395.  short rows=0,num_display_lines=0,num_shadow_lines=0;
  1396.  LINE *curr=NULL;
  1397.  RESERVED *curr_reserved=CURRENT_FILE->first_reserved;
  1398.  short tab_actual_row=calculate_actual_row(CURRENT_VIEW->tab_base,CURRENT_VIEW->tab_off,CURRENT_SCREEN.rows[WINDOW_MAIN]);
  1399.  short scale_actual_row=calculate_actual_row(CURRENT_VIEW->scale_base,CURRENT_VIEW->scale_off,CURRENT_SCREEN.rows[WINDOW_MAIN]);
  1400. /*--------------------------- processing ------------------------------*/
  1401. #ifdef TRACE
  1402.  trace_function("show.c:    find_next_current_line");
  1403. #endif
  1404. /*---------------------------------------------------------------------*/
  1405. /* Determine the number of file lines displayed...                     */
  1406. /*---------------------------------------------------------------------*/
  1407.  num_display_lines = (CURRENT_SCREEN.rows[WINDOW_MAIN]) - 1;
  1408.  for (i=0;curr_reserved!=NULL;i++)
  1409.      curr_reserved = curr_reserved->next;
  1410.  num_display_lines -= i;
  1411.  if (CURRENT_VIEW->scale_on)
  1412.     num_display_lines--;
  1413.  if (CURRENT_VIEW->tab_on)
  1414.     num_display_lines--;
  1415.  if (CURRENT_VIEW->hexshow_on)
  1416.     num_display_lines = num_display_lines - 2;
  1417.  if (CURRENT_VIEW->scale_on
  1418.  &&  CURRENT_VIEW->tab_on
  1419.  &&  tab_actual_row == scale_actual_row)
  1420.     num_display_lines++;
  1421.  
  1422.  curr = lll_find(CURRENT_FILE->first_line,cline);
  1423.  while(num_pages)
  1424.    {
  1425.     rows = num_display_lines;
  1426.     while(rows)
  1427.       {
  1428. /*---------------------------------------------------------------------*/
  1429. /* If the current line is above or below TOF or EOF, set all to blank. */
  1430. /*---------------------------------------------------------------------*/
  1431.        if (curr == NULL)
  1432.          {
  1433.           cline = (direction == DIRECTION_FORWARD) ? CURRENT_FILE->number_lines + 1L : 0L;
  1434.           num_pages = 1L;
  1435.           break;
  1436.          }
  1437. /*---------------------------------------------------------------------*/
  1438. /* If the current line is excluded, increment a running total.         */
  1439. /* Ignore the line if on TOF or BOF.                                   */
  1440. /*---------------------------------------------------------------------*/
  1441.        if (curr->next != NULL                           /* Bottom of file */
  1442.        &&  curr->prev != NULL)                             /* Top of file */
  1443.          {
  1444.           if (!in_scope(curr))
  1445.             {
  1446.              num_shadow_lines++;
  1447.              cline += (LINETYPE)direction;
  1448.              if (direction == DIRECTION_FORWARD)
  1449.                 curr = curr->next;
  1450.              else
  1451.                 curr = curr->prev;
  1452.              continue;
  1453.             }
  1454.          }
  1455. /*---------------------------------------------------------------------*/
  1456. /* If we get here, we have to determine if a shadow line is to be      */
  1457. /* displayed or not.                                                   */
  1458. /*---------------------------------------------------------------------*/
  1459.        if (CURRENT_VIEW->shadow
  1460.        && num_shadow_lines > 0)
  1461.          {
  1462.           num_shadow_lines = 0;
  1463.           rows--;
  1464.           continue;
  1465.          }
  1466.        rows--;
  1467.        cline += (LINETYPE)direction;
  1468.        if (direction == DIRECTION_FORWARD)
  1469.           curr = curr->next;
  1470.        else
  1471.           curr = curr->prev;
  1472.       }
  1473.     num_pages--;
  1474.    }
  1475.  if (direction == DIRECTION_FORWARD
  1476.  &&  cline > CURRENT_FILE->number_lines+1L)
  1477.     cline = CURRENT_FILE->number_lines+1L;
  1478.  if (direction == DIRECTION_BACKWARD
  1479.  &&  cline < 0L)
  1480.     cline = 0L;
  1481.  cline = find_next_in_scope((LINE *)NULL,cline,direction);
  1482. #ifdef TRACE
  1483.  trace_return();
  1484. #endif
  1485.  return(cline);
  1486. }
  1487. /***********************************************************************/
  1488. #ifdef PROTO
  1489. short get_row_for_focus_line(LINETYPE fl,short cr)
  1490. #else
  1491. short get_row_for_focus_line(fl,cr)
  1492. LINETYPE fl;
  1493. short cr;
  1494. #endif
  1495. /***********************************************************************/
  1496. /*---------------------------------------------------------------------*/
  1497. /* Returns the row within the main window where the focus line is      */
  1498. /* placed. If the focus line is off the screen, or out of bounds of the*/
  1499. /* current size of the file; <0 or >number_lines, this returns the     */
  1500. /* current row.                                                        */
  1501. /*---------------------------------------------------------------------*/
  1502. {
  1503. /*-------------------------- external data ----------------------------*/
  1504. /*--------------------------- local data ------------------------------*/
  1505.  register short i=0;
  1506. /*--------------------------- processing ------------------------------*/
  1507. #ifdef TRACE
  1508.  trace_function("show.c:    get_row_for_focus_line");
  1509. #endif
  1510.  for (i=0;i<CURRENT_SCREEN.rows[WINDOW_MAIN];i++)
  1511.    {
  1512.     if (CURRENT_SCREEN.sl[i].line_number == fl)
  1513.       {
  1514. #ifdef TRACE
  1515.        trace_return();
  1516. #endif
  1517.        return(i);
  1518.       }
  1519.    }
  1520. #ifdef TRACE
  1521.  trace_return();
  1522. #endif
  1523.  return(cr);
  1524. }
  1525. /***********************************************************************/
  1526. #ifdef PROTO
  1527. LINETYPE get_focus_line_in_view(LINETYPE fl,unsigned short row)
  1528. #else
  1529. LINETYPE get_focus_line_in_view(fl,row)
  1530. LINETYPE fl;
  1531. unsigned short row;
  1532. #endif
  1533. /***********************************************************************/
  1534. /*---------------------------------------------------------------------*/
  1535. /* Returns a new focus line if the specified focus line is no longer   */
  1536. /* in view, or the same line number if that line is still in view.     */
  1537. /*---------------------------------------------------------------------*/
  1538. {
  1539. /*-------------------------- external data ----------------------------*/
  1540. /*--------------------------- local data ------------------------------*/
  1541.  register unsigned short i=0;
  1542. /*--------------------------- processing ------------------------------*/
  1543. #ifdef TRACE
  1544.  trace_function("show.c:    get_focus_line_in_view");
  1545. #endif
  1546.  for (i=row;i<CURRENT_SCREEN.rows[WINDOW_MAIN];i++)
  1547.    {
  1548.     if (CURRENT_SCREEN.sl[i].line_number != (-1L))
  1549.       {
  1550. #ifdef TRACE
  1551.        trace_return();
  1552. #endif
  1553.        return(CURRENT_SCREEN.sl[i].line_number);
  1554.       }
  1555.    }
  1556.  for (i=row;i>0;i--)
  1557.    {
  1558.     if (CURRENT_SCREEN.sl[i].line_number != (-1L))
  1559.       {
  1560. #ifdef TRACE
  1561.        trace_return();
  1562. #endif
  1563.        return(CURRENT_SCREEN.sl[i].line_number);
  1564.       }
  1565.    }
  1566. /*---------------------------------------------------------------------*/
  1567. /* We should never get here as there would be no editable lines in view*/
  1568. /*---------------------------------------------------------------------*/
  1569. #ifdef TRACE
  1570.  trace_return();
  1571. #endif
  1572.  return(fl);
  1573. }
  1574. /***********************************************************************/
  1575. #ifdef PROTO
  1576. LINETYPE calculate_focus_line(LINETYPE fl,LINETYPE cl)
  1577. #else
  1578. LINETYPE calculate_focus_line(fl,cl)
  1579. LINETYPE fl,cl;
  1580. #endif
  1581. /***********************************************************************/
  1582. /*---------------------------------------------------------------------*/
  1583. /* Returns the new focus line. If the focus line is still in the       */
  1584. /* window, it stays as is. If not,the focus   line becomes the current */
  1585. /* line.                                                               */
  1586. /*---------------------------------------------------------------------*/
  1587. {
  1588. /*-------------------------- external data ----------------------------*/
  1589. /*--------------------------- local data ------------------------------*/
  1590.  LINETYPE new_fl=(-1L);
  1591.  register short i=0;
  1592. /*--------------------------- processing ------------------------------*/
  1593. #ifdef TRACE
  1594.  trace_function("show.c:    calculate_focus_line");
  1595. #endif
  1596.  for (i=0;i<CURRENT_SCREEN.rows[WINDOW_MAIN];i++)
  1597.   {
  1598.    if (CURRENT_SCREEN.sl[i].line_number == fl
  1599.    &&  (CURRENT_SCREEN.sl[i].line_type == LINE_LINE
  1600.      || CURRENT_SCREEN.sl[i].line_type == LINE_TOF_EOF))
  1601.      {
  1602.       new_fl = fl;
  1603.       break;
  1604.      }
  1605.   }
  1606.  if (new_fl == (-1L))
  1607.     new_fl = cl;
  1608. #ifdef TRACE
  1609.  trace_return();
  1610. #endif
  1611.  return(new_fl);
  1612. }
  1613. /***********************************************************************/
  1614. #ifdef PROTO
  1615. static void show_hex_line(short row)
  1616. #else
  1617. static void show_hex_line(row)
  1618. short row;
  1619. #endif
  1620. /***********************************************************************/
  1621. {
  1622. /*-------------------------- external data ----------------------------*/
  1623. /*--------------------------- local data ------------------------------*/
  1624.  register short i=0;
  1625.  chtype ch=0;
  1626.  LENGTHTYPE vcol=0,vend=0,vlen=0;
  1627.  LENGTHTYPE length=0;
  1628.  CHARTYPE *line=NULL;
  1629.  int num=0;
  1630. /*--------------------------- processing ------------------------------*/
  1631. #ifdef TRACE
  1632.  trace_function("show.c:    show_hex_line");
  1633. #endif
  1634. /*---------------------------------------------------------------------*/
  1635. /* Set up columns to display...                                        */
  1636. /*---------------------------------------------------------------------*/
  1637.  vcol = CURRENT_VIEW->verify_col - 1;
  1638.  vend = CURRENT_VIEW->verify_end - 1;
  1639.  vlen = CURRENT_VIEW->verify_end - CURRENT_VIEW->verify_start + 1;
  1640.  length = CURRENT_SCREEN.sl[row].length;
  1641.  line = CURRENT_SCREEN.sl[row].contents;
  1642. #if defined(USE_EXTCURSES)
  1643.  wattrset(CURRENT_WINDOW_MAIN,CURRENT_SCREEN.sl[row].normal_colour);
  1644. #endif
  1645.  wmove(CURRENT_WINDOW_MAIN,row,0);
  1646.  for (i=0;i<CURRENT_SCREEN.cols[WINDOW_MAIN];i++)
  1647.    {
  1648. /*---------------------------------------------------------------------*/
  1649. /* If the last character in the line has been displayed, display blank.*/
  1650. /*---------------------------------------------------------------------*/
  1651.     if (i+vcol < length)
  1652.        ch = *(line+i+vcol);
  1653.     else
  1654.        ch = ' ';
  1655. /*---------------------------------------------------------------------*/
  1656. /* If we have gone past the VERIFY END column, display a blank.        */
  1657. /*---------------------------------------------------------------------*/
  1658.     if (i >= vlen)
  1659.        ch = ' ';
  1660. /*---------------------------------------------------------------------*/
  1661. /* Calculate the HEX character to display based on which HEXSHOW line  */
  1662. /* is being displayed.                                                 */
  1663. /*---------------------------------------------------------------------*/
  1664.     if (CURRENT_SCREEN.sl[row].other_start_col == 0)
  1665.        num = (int)((ch / 16) + (int)'0');
  1666.     else
  1667.        num = (int)((ch % 16) + (int)'0');
  1668.     num = (num > (int)'9') ? num + 7 : num;
  1669. #if defined(USE_EXTCURSES)
  1670.     ch = (chtype)num;
  1671. #else
  1672.     ch = (chtype)num | CURRENT_SCREEN.sl[row].normal_colour;
  1673. #endif
  1674. /*---------------------------------------------------------------------*/
  1675. /* Go and display the character...                                     */
  1676. /*---------------------------------------------------------------------*/
  1677.     put_char(CURRENT_WINDOW_MAIN,ch,ADDCHAR);
  1678.    }
  1679. #ifdef TRACE
  1680.  trace_return();
  1681. #endif
  1682.  return;
  1683. }
  1684. /***********************************************************************/
  1685. #ifdef PROTO
  1686. void get_current_position(LINETYPE *line,short *col)
  1687. #else
  1688. void get_current_position(line,col)
  1689. LINETYPE *line;
  1690. short *col;
  1691. #endif
  1692. /***********************************************************************/
  1693. {
  1694. /*-------------------------- external data ----------------------------*/
  1695.  extern short prefix_width;
  1696. /*--------------------------- local data ------------------------------*/
  1697.  short y=0,x=0;
  1698. /*--------------------------- processing ------------------------------*/
  1699. #ifdef TRACE
  1700.  trace_function("show.c:    get_current_position");
  1701. #endif
  1702.  getyx(CURRENT_WINDOW,y,x);
  1703.  switch(CURRENT_VIEW->current_window)
  1704.    {
  1705.     case WINDOW_COMMAND:
  1706.          *line = CURRENT_VIEW->current_line;
  1707.          *col = ++x;
  1708.          break;
  1709.     case WINDOW_MAIN:
  1710.          *line = CURRENT_VIEW->focus_line;
  1711.          *col = x + CURRENT_VIEW->verify_col;
  1712.          break;
  1713.     case WINDOW_PREFIX:
  1714.          *line = CURRENT_VIEW->focus_line;
  1715.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT
  1716.          &&  prefix_width != PREFIX_WIDTH)
  1717.             ;
  1718.          else
  1719.             x++;
  1720.          *col = x;
  1721.          break;
  1722.    }
  1723. #ifdef TRACE
  1724.  trace_return();
  1725. #endif
  1726.  return;
  1727. }
  1728. /***********************************************************************/
  1729. #ifdef PROTO
  1730. void calculate_new_column(COLTYPE current_screen_col,LENGTHTYPE current_verify_col,
  1731.                           LENGTHTYPE new_file_col,COLTYPE *new_screen_col, LENGTHTYPE *new_verify_col)
  1732. #else
  1733. void calculate_new_column(current_screen_col,current_verify_col,new_file_col,new_screen_col,new_verify_col)
  1734. COLTYPE current_screen_col;
  1735. LENGTHTYPE current_verify_col,new_file_col;
  1736. COLTYPE *new_screen_col;
  1737. LENGTHTYPE *new_verify_col;
  1738. int percent;
  1739. #endif
  1740. /***********************************************************************/
  1741. {
  1742. /*-------------------------- external data ----------------------------*/
  1743. /*--------------------------- local data ------------------------------*/
  1744.  LENGTHTYPE min_file_col=0,max_file_col=0;
  1745.  LINETYPE x=0,temp_new_file_col=new_file_col,verify_width=0L;
  1746. /*--------------------------- processing ------------------------------*/
  1747. #ifdef TRACE
  1748.  trace_function("show.c:    calculate_new_column");
  1749. #endif
  1750.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  1751.    {
  1752.     *new_screen_col = (LENGTHTYPE)(new_file_col);
  1753. #ifdef TRACE
  1754.     trace_return();
  1755. #endif
  1756.     return;
  1757.    }
  1758.  
  1759.  min_file_col = CURRENT_VIEW->verify_col - 1;
  1760. #ifdef VERSHIFT
  1761.  max_file_col = min_file_col + min(CURRENT_SCREEN.cols[WINDOW_MAIN] - 1,CURRENT_VIEW->verify_end - CURRENT_VIEW->verify_start);
  1762.  verify_width = max_file_col - min_file_col + 1;
  1763. #else
  1764.  max_file_col = CURRENT_VIEW->verify_col + CURRENT_SCREEN.cols[WINDOW_MAIN] - 2;
  1765. #endif
  1766.  
  1767.  if (temp_new_file_col >= min_file_col
  1768.  &&  temp_new_file_col <= max_file_col)            /* new column in display */
  1769.    {
  1770.     *new_screen_col = (LENGTHTYPE)(temp_new_file_col - (current_verify_col - 1));
  1771.     *new_verify_col = current_verify_col;
  1772. #ifdef TRACE
  1773.     trace_return();
  1774. #endif
  1775.     return;
  1776.    }
  1777. /*---------------------------------------------------------------------*/
  1778. /* To get here, we have new verify column...                           */
  1779. /*---------------------------------------------------------------------*/
  1780. #ifdef VERSHIFT
  1781.  x = verify_width / 2;
  1782. #else
  1783.  x = CURRENT_SCREEN.cols[WINDOW_MAIN] / 2;
  1784. #endif
  1785.  *new_verify_col = (LENGTHTYPE)max(1,temp_new_file_col - x + 2);
  1786.  *new_screen_col = (LENGTHTYPE)((*new_verify_col == 1) ? temp_new_file_col : x - 1);
  1787. #ifdef TRACE
  1788.  trace_return();
  1789. #endif
  1790.  return;
  1791. }
  1792.